package com.chenfwind.serviceImpl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.chenfwind.IDao.BookMapper;
import com.chenfwind.IDao.FriendMapper;
import com.chenfwind.IDao.ShareRecodeMapper;
import com.chenfwind.domain.Friend;
import com.chenfwind.domain.ShareRecode;
import com.chenfwind.service.ShareRecodeService;

@Service("shareRecodeService")
public class ShareRecodeServiceImpl implements ShareRecodeService {

	@Autowired
	private ShareRecodeMapper ShareRecodeDao;
	@Autowired
	private FriendMapper friendDao;
	
	public int save(ShareRecode shareRecode){
		return ShareRecodeDao.insertSelective(shareRecode);
	}
	
	public List<ShareRecode> getRecodeByUser(String userId){
//		List<ShareRecode> shareList = ShareRecodeDao.getRecodeByUser;
		/*
		List<String> userIDList = friendService.getFriendUserIDByUserID();
		*/
		List<Friend> friendList = friendDao.selectFriendByUserId(userId);
		List<String> userIDList = new ArrayList<String>();
		for (Friend friend : friendList) {
			userIDList.add(friend.getUser2Id());
		}
		userIDList.add(userId);
		return ShareRecodeDao.selectRecodeByUser(userIDList);
	}
}
